<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var arr = [
        1, 324, 54, 5, 6, 54, 1, 324, 54, 5, 6, 54, 6, 1, 324, 54, 5, 6, 54, 76,
      ];
      // console.log(arr.length);
      // 方法一
      // 升序
      // 注意！！不能用sort()
      var beforeArr = arr.slice(0, 10).sort((a, b) => {
        return a - b;
      });
      // 降序
      var afterArr = arr.slice(10).sort((a, b) => {
        return b - a;
      });

      var endArr = beforeArr.concat(afterArr);

      console.log(endArr);
    </script>
  </body>
</html>
